-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add formats option for specifying allowed formats #4053
Conversation
5c2b7b3
to
17e8d67
Compare
packages/quill/src/core/quill.ts
Outdated
(errorMessage) => { | ||
debug.error(errorMessage); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably just pass in the debug
object for ease and flexibility
} | ||
let iterations = 0; | ||
while (format) { | ||
registry.register(format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should suppress the warning in case two formats have the same requiredContainer
|
||
iterations += 1; | ||
if (iterations > MAX_REGISTER_ITERATIONS) { | ||
logError(`Maximum iterations reached when registering "${name}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message could be more descriptive ex "Cycle detected in registering blot requiredContainer"
A list of format names to whitelist. If not given, all formats are allowed. | ||
For advance usages, see [Registries](/docs/registries/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the requirement is stronger than just allowing or blocking now.
A list of formats that are recognized and can exist within the editor contents. By default, all formats that are defined in the Quill library are allowed. To restrict formatting to a smaller list, pass in an array of the format names to support. You can create brand new formats or more fully customize the content using [Registries](/docs/registries/). Specifying a `registry` option will ignore this `formats` option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also probably document the registry configuration option on this page for completeness.
### registry
Default: `null`
By default all formats defined by Quill are supported in the editor contents through a shared registry between editor instances. Use `formats` to restrict formatting for simple use cases and `registry` for greater customization. Specifying this `registry` option will ignore the `formatting` option. Learn more about [Registries](/docs/registries/).
@@ -104,3 +104,41 @@ quill.setContents( | |||
### theme | |||
|
|||
Name of theme to use. The builtin options are `"bubble"` or `"snow"`. An invalid or falsy value will load a default minimal theme. Note the theme's specific stylesheet still needs to be included manually. See [Themes](/docs/themes/) for more information. | |||
|
|||
### formats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep configuration options alphabetized since it's a reference and will make it easier to find.
Achieve a similar purpose as
registry
option but it's easier to use. As in most cases users don't need to overload a format to have different implementations.